package com.hhh.petadopt.serviceImpl;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.hhh.petadopt.mapper.LostAndFoundMapper;
import com.hhh.petadopt.pojo.Lost;
import com.hhh.petadopt.pojo.LostMessage;
import com.hhh.petadopt.service.LostAndFoundService;
/**
 * 失物招领
 * @author 杜镇声声
 *
 */
@Service
public class LostAndFoundServiceImpl implements LostAndFoundService {

	@Autowired
	private LostAndFoundMapper lostAndFoundMapper;
	@Override
	public List<Lost> selectLostAndfound() {
		//执行查询
		List<Lost> lostList = lostAndFoundMapper.selectLostListLimited();
		//返回数据
		return lostList;
	}
	
	//失物招领详情
	@Override
	public Lost selectLostById(Integer id) {
		//执行查询
		Lost lost = lostAndFoundMapper.selectLostById(id);
		//将时间转换为yyyy-mm-dd类型
		lost.setLosttime(lost.getLosttime().substring(0, 10));
		return lost;
	}

	//查询留言
	@Override
	public List<LostMessage> selectMessages(String lid) {
		List<LostMessage> mesaagelist = lostAndFoundMapper.selectMEssageList(lid);
		return mesaagelist;
	}
	

	//插入留言
	@Override
	public void inertMessage(LostMessage lmessage) {
		//补全信息
		//留言展示状态
		lmessage.setIsshow("1"); //1表示展示，2表示不展示
		lmessage.setLldate(new Date());
		//执行操作
		lostAndFoundMapper.insertmeassage(lmessage);
		
	}
	

}
